# from typing import List
#
# from pymilvus import (
#     MilvusClient,
#     DataType,
#     Function,
#     FunctionType,
#     AnnSearchRequest,
#     RRFRanker,
# )
#
# from app.utils import get_milvus_client
#
# client = get_milvus_client()
#
# analyzer_params = {"tokenizer": "standard", "filter": ["lowercase"]}
#
# schema = MilvusClient.create_schema()
# schema.add_field(
#     field_name="id",
#     datatype=DataType.VARCHAR,
#     is_primary=True,
#     auto_id=True,
#     max_length=100,
# )
# schema.add_field(
#     field_name="content",
#     datatype=DataType.VARCHAR,
#     max_length=65535,
#     analyzer_params=analyzer_params,
#     enable_match=True,  # Enable text matching
#     enable_analyzer=True,  # Enable text analysis
# )
# schema.add_field(field_name="sparse_vector", datatype=DataType.SPARSE_FLOAT_VECTOR)
# schema.add_field(
#     field_name="dense_vector",
#     datatype=DataType.FLOAT_VECTOR,
#     dim=1024,  # Dimension for text-embedding-3-small
# )
# schema.add_field(field_name="metadata", datatype=DataType.JSON)
#
# schema.add_field(field_name="cate", datatype=DataType.VARCHAR, max_length=1000,)
# schema.add_field(field_name="fileName", datatype=DataType.VARCHAR, max_length=1000)
# schema.add_field(field_name="year", datatype=DataType.VARCHAR, max_length=1000)
# schema.add_field(field_name="month", datatype=DataType.VARCHAR, max_length=1000)
# schema.add_field(field_name="tags", datatype=DataType.VARCHAR, max_length=1000)
# schema.add_field(field_name="summary", datatype=DataType.VARCHAR, max_length=65535)
# bm25_function = Function(
#     name="bm25",
#     function_type=FunctionType.BM25,
#     input_field_names=["content"],
#     output_field_names="sparse_vector",
# )
#
#
# collection_name = "sfat_metadata2"
# schema.add_function(bm25_function)
# index_params = MilvusClient.prepare_index_params()
# index_params.add_index(
#     field_name="sparse_vector",
#     index_type="SPARSE_INVERTED_INDEX",
#     metric_type="BM25",
# )
# index_params.add_index(field_name="dense_vector", index_type="FLAT", metric_type="IP")
#
# if client.has_collection(collection_name):
#     client.drop_collection(collection_name)
# client.create_collection(
#     collection_name=collection_name,
#     schema=schema,
#     index_params=index_params,
# )
# print(f"Collection '{collection_name}' created successfully")
#
#
#
